# coding=utf-8

"""
    Created by Kalyter on 2017-10-27.
"""
import socket

HOST = ''
PORT = 50007

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((HOST, PORT))

s.listen(1)
connection, address = s.accept()

print('Connected by', address)

while True:
    data = connection.recv(1024)
    if not data:
        break
    print('receive: ', data)
    connection.sendall(data)

connection.close()
